﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
using DotNetOpenAuth.OpenId.Extensions.AttributeExchange;
using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration;
namespace cnFederal.Admin
{
    public partial class Login : System.Web.UI.Page
    {
        OpenIdRelyingParty rp;
        public Login()
        {        
            rp = new OpenIdRelyingParty();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
             
              var r = rp.GetResponse();
                if (r != null)
                  {
                      switch (r.Status)
                               {
                                 case AuthenticationStatus.Authenticated:
                                        NotLoggedIn.Visible = false;
                                        Session["GoogleIdentifier"] = r.ClaimedIdentifier.ToString();
                                       // var openidRequest = rp.CreateRequest("https://www.google.com/accounts/o8/id");
                                        break;
                                 case AuthenticationStatus.Canceled:
                                        lblAlertMsg.Text = "Cancelled.";
                                        break;
                                 case AuthenticationStatus.Failed:
                                        lblAlertMsg.Text = "Login Failed.";
                                        break;
                               }
                 }

               
        
        }


     
        protected void OpenLogin_Click(object src, CommandEventArgs e)
        {
           
            OpenIdRelyingParty openid = new OpenIdRelyingParty();
            string discoveryUri = @"https://www.google.com/accounts/o8/id";
            var b = new UriBuilder(Request.Url) { Query = "" };
            var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri);
            req.RedirectToProvider();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
     
          
        }

  


        

       
    }
}